1 /*
2 AntMake
3
4 Copyright (C) 2004 Jose San Leandro Armend?riz
5 jsanleandro@yahoo.es
6 chousz@yahoo.com
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public
10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
17
18 You should have received a copy of the GNU General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
22 Thanks to ACM S.L. for distributing this library under the GPL license.
23 Contact info: jsr000@terra.es
24 Postal Address: c/Playa de Lagoa, 1
25 Urb. Valdecaba?as
26 Boadilla del monte
27 28660 Madrid
28 Spain
29
30 ******************************************************************************
31 This class is based on RedirectingStreamHandler
32 included in Ant distribution, and whose license details
33 are the following.
34
35 *
36 * The Apache Software License, Version 1.1
37 *
38 * Copyright (c) 2002 The Apache Software Foundation. All rights
39 * reserved.
40 *
41 * Redistribution and use in source and binary forms, with or without
42 * modification, are permitted provided that the following conditions
43 * are met:
44 *
45 * 1. Redistributions of source code must retain the above copyright
46 * notice, this list of conditions and the following disclaimer.
47 *
48 * 2. Redistributions in binary form must reproduce the above copyright
49 * notice, this list of conditions and the following disclaimer in
50 * the documentation and/or other materials provided with the
51 * distribution.
52 *
53 * 3. The end-user documentation included with the redistribution, if
54 * any, must include the following acknowlegement:
55 * "This product includes software developed by the
56 * Apache Software Foundation (http://www.apache.org/)."
57 * Alternately, this acknowlegement may appear in the software itself,
58 * if and wherever such third-party acknowlegements normally appear.
59 *
60 * 4. The names "Ant" and "Apache Software
61 * Foundation" must not be used to endorse or promote products derived
62 * from this software without prior written permission. For written
63 * permission, please contact apache@apache.org.
64 *
65 * 5. Products derived from this software may not be called "Apache"
66 * nor may "Apache" appear in their names without prior written
67 * permission of the Apache Group.
68 *
69 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
70 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
71 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
72 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
73 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
74 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
75 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
76 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
77 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
78 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
79 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
80 * SUCH DAMAGE.
81 * ====================================================================
82 *
83 * This software consists of voluntary contributions made by many
84 * individuals on behalf of the Apache Software Foundation. For more
85 * information on the Apache Software Foundation, please see
86 * <http://www.apache.org/>.
87 *
88
89 ******************************************************************************
90 *
91 * Filename: $RCSfile: AntMakeTask.java,v $
92 *
93 * Author: Jose San Leandro Armend?riz
94 *
95 * Description: Do-nothing handler to allow redirection of the stream
96 * to the cvs log's output parser.
97 *
98 * Last modified by: $Author: chous $ at $Date: 2004/01/24 11:17:06 $
99 *
100 * File version: $Revision: 1.8 $
101 *
102 * Project version: $Name: $
103 *
104 * $Id: AntMakeTask.java,v 1.8 2004/01/24 11:17:06 chous Exp $
105 *
106 */
107 package org.acmsl.antmake;
108
109 /*
110 * Importing JDK classes.
111 */
112 import java.io.ByteArrayOutputStream;
113 import java.io.IOException;
114
115 /*
116 * Importing Ant classes.
117 */
118 import org.apache.tools.ant.BuildException;
119 import org.apache.tools.ant.taskdefs.PumpStreamHandler;
120
121 /*
122 * Importing Commons Logging classes.
123 */
124 import org.apache.commons.logging.LogFactory;
125
126 /***
127 * Do-nothing handler to allow redirection of the stream
128 * to the cvs log's output parser.
129 * @author <a href="mailto:jsanleandro@yahoo.es"
130 >Jose San Leandro</a>, based on
131 * <a href="mailto:peter@apache.org">Peter Donald</a>'s
132 * RedirectingStreamHandler. It's package-protected, so it had to be
133 * basically copied and pasted.
134 * @version $Revision: 1.8 $
135 * @see org.apache.tools.ant.taskdefs.cvslib.RedirectingStreamHandler
136 */
137 public class RedirectingStreamHandler
138 extends PumpStreamHandler
139 {
140 /***
141 * Creates a RedirectingStreamHandler for given parser.
142 * @param parser the parser.
143 */
144 public RedirectingStreamHandler(ChangeLogParser parser)
145 {
146 super(
147 new RedirectingOutputStream(parser),
148 new ByteArrayOutputStream());
149 }
150
151 /***
152 * Retrieves the errors.
153 * @return such errors.
154 */
155 public String getErrors()
156 {
157 String result = "";
158
159 try
160 {
161 ByteArrayOutputStream t_baosErrors =
162 (ByteArrayOutputStream) getErr();
163
164 result = t_baosErrors.toString("ASCII");
165 }
166 catch (IOException ioException)
167 {
168 LogFactory.getLog(RedirectingStreamHandler.class).warn(
169 "Error redirecting the stream",
170 ioException);
171 }
172
173 return result;
174 }
175
176 /***
177 * Stops the stream flow.
178 */
179 public void stop()
180 throws BuildException
181 {
182 super.stop();
183
184 try
185 {
186 getErr().close();
187 getOut().close();
188 }
189 catch (IOException ioException)
190 {
191 // plain impossible
192 throw new BuildException(ioException);
193 }
194 }
195 }
196
This page was automatically generated by Maven